import 'package:flutter/material.dart';
class KeepAliveWrapper extends StatefulWidget {
  final Widget child;
  final bool keepAlive;
  const KeepAliveWrapper({super.key, required this.child, this.keepAlive = true});

  @override
  State<KeepAliveWrapper> createState() => _KeepAliveWrapperState();
}

class _KeepAliveWrapperState extends State<KeepAliveWrapper>
    with AutomaticKeepAliveClientMixin {
  @override
  bool get wantKeepAlive => widget.keepAlive;

  @override
  Widget build(BuildContext context) {
    super.build(context);
    return widget.child;
  }
}

// class KeepAliveWidget extends StatefulWidget {
//   const KeepAliveWidget({super.key, required this.child});
//
//   final Widget child;
//
//   @override
//   State<KeepAliveWidget> createState() => _KeepAliveWidgetState();
// }
//
// class _KeepAliveWidgetState extends State<KeepAliveWidget> with AutomaticKeepAliveClientMixin {
//   @override
//   Widget build(BuildContext context) {
//     super.build(context);
//     return widget.child;
//   }
//
//   @override
//   bool get wantKeepAlive => true;
// }